<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Checks whether a property is initialized</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="reflectionproperty.isdefault.html">« ReflectionProperty::isDefault</a></li>
      <li style="float: right;"><a href="reflectionproperty.isprivate.html">ReflectionProperty::isPrivate »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.reflectionproperty.html">ReflectionProperty</a></li>
    <li>Checks whether a property is initialized</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="reflectionproperty.isinitialized" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionProperty::isInitialized</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.4.0, PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionProperty::isInitialized</span> &mdash; <span class="dc-title">Checks whether a property is initialized</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionproperty.isinitialized-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionProperty::isInitialized</strong></span>(<span class="methodparam"><span class="type">?</span><span class="type"><span class="type">object</span><span class="type"></span></span> <code class="parameter">$object</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   Checks whether a property is initialized.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionproperty.isinitialized-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">object</code></dt>

    <dd>

     <p class="para">
      If the property is non-static an object must be provided to fetch the
      property from.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionproperty.isinitialized-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns <strong><code>false</code></strong> for typed properties prior to initialization,
   and for properties that have been explicitly <span class="function"><a href="function.unset.html" class="function">unset()</a></span>.
   For all other properties <strong><code>true</code></strong> will be returned.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-reflectionproperty.isinitialized-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   Throws a <span class="classname"><a href="class.reflectionexception.html" class="classname">ReflectionException</a></span> if the property is inaccessible.
   You can make a protected or private property accessible using
   <span class="methodname"><a href="reflectionproperty.setaccessible.html" class="methodname">ReflectionProperty::setAccessible()</a></span>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-reflectionproperty.isinitialized-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">object</code> is nullable now.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-reflectionproperty.isinitialized-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="reflectionproperty.isinitialized.example.basic">
   <p><strong>示例 #1 <span class="methodname"><strong>ReflectionProperty::isInitialized()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">User<br /></span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;</span><span style="color: #0000BB">string&nbsp;$name</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$rp&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ReflectionProperty</span><span style="color: #007700">(</span><span style="color: #DD0000">'User'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'name'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$user&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">User</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$rp</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">isInitialized</span><span style="color: #007700">(</span><span style="color: #0000BB">$user</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$user</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">name&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'Nikita'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$rp</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">isInitialized</span><span style="color: #007700">(</span><span style="color: #0000BB">$user</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
bool(false)
bool(true)
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionproperty.isinitialized-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="methodname"><a href="reflectionproperty.hastype.html" class="methodname" rel="rdfs-seeAlso">ReflectionProperty::hasType()</a> - Checks if property has a type</span></li>
  </ul>
 </div>


</div></div></div></body></html>